// const { ipcRenderer } = require('electron')
import {ipcRenderer} from 'electron'
document.addEventListener('mousedown', function (event) {
  const startX = event.x
  const startY = event.y

  document.addEventListener('mousemove', onMouseMove)
  document.addEventListener('mouseup', onMouseUp)

  function onMouseMove(moveEvent) {
    const width = Math.abs(moveEvent.x - startX)
    const height = Math.abs(moveEvent.y - startY)
    // Update the selection overlay here
  }

  function onMouseUp(upEvent) {
    document.removeEventListener('mousemove', onMouseMove)
    document.removeEventListener('mouseup', onMouseUp)
    ipcRenderer.send('capture-screen', {
      x: Math.min(startX, upEvent.x),
      y: Math.min(startY, upEvent.y),
      width: Math.abs(upEvent.x - startX),
      height: Math.abs(upEvent.y - startY)
    })
  }
})
 